<?
class OrderRecord_gly extends OrderRecord{
	
	
	public function cancel($operator, $concat_id=0){
		
		
		$orders= $this->info_n(7517);
		
        $array=array();
        $array[] = $orders['mainOrder'];
        if($orders['mainOrder']->UUordermode==0){
			if($operator!=$orders['mainOrder']->UUaid){// 非最下级销售者
				if($operator!=$orders['mainOrder']->UUmid) throw new Exception("非自身订单，无权取消");
			}
        }
        else{
			
            if (isset($_SESSION['mobile']) && !empty($_SESSION['mobile'])) {
                $account = $_SESSION['mobile'];
            } else {
                $str="select account from pft_member where id=$operator limit 1";
                $GLOBALS['le']->query($str);
                $GLOBALS['le']->fetch_assoc();
                $account = $GLOBALS['le']->f("account");
            }

            if( $account!='123999' && $account !=(string)$orders['mainOrder']->UUcontacttel)
                throw new Exception("非游客自身订单，无权取消{$account}--{$orders['mainOrder']->UUcontacttel}");
        }
        if ($orders['mainOrder']->UUp_type=='F' || $orders['mainOrder']->UUconcat_id==0) {
			$tuikuan = ((string)$orders['mainOrder']->UUpaystatus==2 || (string)$orders['mainOrder']->UUstatus==2) ? 1:0; 
            $res = $this->s->Order_Change_Pro((string)$orders['mainOrder']->UUordernum,0,-1,$tuikuan,$operator);
            if($res!=100) return array("code"=>101,"msg"=>$res);
        }
        else {
            $array = array_merge($orders['childOrder'], $array);

            foreach($array as $row){
				// 过期跟未支付不退款
				$tuikuan = ((string)$row->UUpaystatus==2 || (string)$row->UUstatus==2) ? 1:0; 
				echo "Order_Change_Pro(".(string)$row->UUordernum.",0,-1,$tuikuan,$operator)";
                $res = $this->s->Order_Change_Pro((string)$row->UUordernum,0,-1,$tuikuan,$operator);
				echo $res;
                if($res!=100) return array("code"=>101,"msg"=>$res);
            }
        }

        return array("code"=>100,"msg"=>$res);
	}
	
}

?>